package com.xsz.controller;

import com.xsz.entity.Possition;
import com.xsz.service.PossitionService;
import com.xsz.util.ResultVOUtil;
import com.xsz.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("possition")
@Api(value = "用户控制类")
public class PossitionController {
    @Resource
    PossitionService possitionService;

    @ApiOperation(value = "创建API")
    @PostMapping("/register")
    public ResultVO add(@RequestBody Possition possition){
        return ResultVOUtil.success(possitionService.add(possition));
    }

    @ApiOperation(value = "修改API")
    @PostMapping("/update")
    public ResultVO update(@RequestBody Possition possition){
        return ResultVOUtil.success(possitionService.update(possition));
    }

    @ApiOperation(value = "删除API")
    @PostMapping("/delete/{id}")
    public ResultVO delete(@PathVariable("id") String id){
        possitionService.delete(id);
        return  ResultVOUtil.success();
    }

//    @ApiOperation(value = "查询API")
//    @PostMapping("/showAll")
//    public ResultVO selectAll(){
//        return ResultVOUtil.success(possitionService.getAll());
//    }

    @ApiOperation(value = "分页返回所有职位")
    @RequestMapping("listAll")
    public ResultVO list(HttpServletRequest request){
        String startpage=request.getParameter("start");
        return  ResultVOUtil.success(possitionService.getAll(startpage, "5"));
    }

    @ApiOperation(value = "根据登录账户id分页返回所有职位")
    @RequestMapping("listAllById")
    public ResultVO listById(HttpServletRequest request){
        String startpage=request.getParameter("start");
        return  ResultVOUtil.success(possitionService.getAllById(startpage, "5"));
    }

    @ApiOperation(value = "根据职位id查询职位信息")
    @GetMapping("/showById/{id}")
    public ResultVO selectById(@PathVariable("id") String id){
        return  ResultVOUtil.success(possitionService.selectById(id));
    }



}
